(function (G) {
    G.vue({
        data: {
            rows:[],
            models:{}
        },
        methods: {
            edit(event){
                let index = event.currentTarget.dataset.index
                var modeleditquery = {
                    values: index == -1 ? {} : this.data.rows[index],
                    title: index == -1 ? '发起安全培训' : '安全培训',
                    meth: index == -1 ? 'POST' : 'PUT',
                    models: this.data.models,
                    url: '/api/model/security_training',
                    submit:data=>{
                        return data;
                    },
                    refresh:()=>{
                        this.getList()
                    }
                }
                modeleditquery.values.userId = G.Storage.get('userInfo').userId
                modeleditquery.models.userId = null
                G.Storage.set('modeleditquery', modeleditquery)
                G.$go('/pages/model/edit/edit')
            },
            getList(){
                G.get('/api/model/security_training?join=user').then(res => {
                    for(let i = 0; i < res.length; i ++){
                        res[i].meeting_time_show = G.date(res[i].meeting_time).Format('yyyy-MM-dd hh:mm:ss')
                    }
                    this.setData({
                        rows:res
                    })
                })
            }
        },
        mounted(query) {
            this.getList()
            G.get('/model/security_training',{},null,{storageName:'model_security_training'}).then(models => {
                this.data.models = models
            })
        }
    })
})(wx.$)